package net.cl.mvc.config;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import net.cl.mvc.Globals;
import net.cl.mvc.wrappers.ActionContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ActionMapping {

	private static final Log log = LogFactory.getLog(ActionMapping.class);
	private static final Properties p = new Properties();

	public static void initMapping() {
		String actionMappingFilePath = Configuration.getFilterConfigInitParameter("actionMappingFilePath");
		String path = actionMappingFilePath == null ? ActionContext.getRealPath(Globals.URL_MAPPING_PATH)
				: ActionContext.getRealPath(actionMappingFilePath);
		try {
			p.load(new FileInputStream(path));
		} catch (IOException e) {
			log.error("Load urlmapping.properties error.");
		}
	}

	public static String getMapping(String url) {
		return p.getProperty(url);
	}

}
